Page({
  /**
   * 页面的初始数据
   */
  data: {
    emptyType: false,
    getdata: {},
    key: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getKey(options.id)
  },
    
  getKey(id) {
    let that = this
    wx.cloud.callFunction({
      name: 'getKey',
      data: {
        name: 'histroyToday'
      }
    }).then(res => {
      console.log(res.result.data[0].key)
      that.setData({
        key: res.result.data[0].key
      })
      this.getData(id)
    })
  },
  getData(id) {
    wx.showLoading({
      title: '加载中',
    });
    let that = this
    wx.request({
      url: "https://v.juhe.cn/todayOnhistory/queryDetail.php?key="+that.data.key+"&e_id=" + id,
      data: {
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        wx.hideLoading();
        if (res.data.reason == "success") {
          that.setData({
            emptyType: true,
            getdata: res.data.result[0]
          })
        } else {
          that.setData({
            emptyType: false
          })
        }
      }
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})